{% extends 'index.html' %}
{% block page-content %}
<div id="page-wrapper">
    <div class="row">
         <div class="col-lg-12">
              <h1 class="page-header"><i class="fa  fa-print  "></i> 计划任务操作日志</h1>
         </div>
                <!-- /.col-lg-12 -->
    </div>
	<div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                           	<i class="fa   fa-gear"></i> 操作日志
                        </div>
                        <div class="panel-body">

				                            
				           <ul class="nav nav-tabs">
				              <li class="active"><a href="#profile" data-toggle="tab"><i class="fa fa-clock-o"></i> 计划任务</a>
				              </li>			              
				           </ul>
				
				                            
				           <div class="tab-content">
				              <div class="tab-pane fade in active" id="profile">
				                   <div class="row">
				                   		<div class="col-lg-12">
				                   			<br>
				                            <table width="100%" class="table table-striped table-bordered table-hover" id="cronTableList">
				                                <thead>
				                                    <tr>
				                                    	<th class="text-center">任务id</th>
				                                    	<th class="text-center">操作用户</th>
				                                        <th class="text-center">任务名称</th>
				                                        <th class="text-center">操作内容</th>
				                                        <th class="text-center">服务器</th>
				                                        <th class="text-center">操作时间</th>
				                                        {% if perms.opsmanage_log_cron_config.delete_log_cron_config %}
				                                        	<th class="text-center">操作</th>
				                                        {% endif %}					                                        
				                                    </tr>
				                                </thead>
				                                <tbody>
				                                	{% for ds in cronList %}
				                                		<tr class="odd gradeX" id="cronLogs-{{ds.id}}">
				                                			<td class="text-center">
				                                				 <a href="/cron_mod/{{ds.cron_id}}/">{{ds.cron_id}}</a>
				                                			</td>
				                                			<td class="text-center">{{ds.cron_user}} </td>
				                                			<td class="text-center">{{ds.cron_name}} </td>
				                                			<td class="text-center">{{ds.cron_content}} </td>
				                                			<td class="text-center">{{ds.cron_server}} </td>
				                                			<td class="text-center">{{ds.create_time|date:"Y/m/d H:i  "}} </td>
				                                			{% if perms.opsmanage_log_cron_config.delete_log_cron_config %}
					                                			<td class="text-center">
					                                				<a href="javascript:" onclick="deleteCronLogs(this,{{ds.id}})">
						                                				<button class="btn btn-danger btn-xs">					                                					
																			<i class="glyphicon glyphicon-trash  bigger-110 icon-only"></i>
																		</button>
																	</a>
																</td>
															{% endif %}					                                			
				                                		</tr>
				                                	{% endfor %}
				                                </tbody>
				                            </table>
										{% if cronList %}
											<ul class="pagination">
											        {% if cronList.has_previous %}
											            <li><a href="/cron_log/{{ cronList.previous_page_number }}/">&laquo;</a></li>
											        {% endif %}
											        {% for page in cronList.paginator.page_range %}
											        	{% if cronList.number == page %}
											        		<li class="disabled"><a href="/cron_log/{{page}}/">{{page}}</a></li>
											        	{% else %}
											        		<li><a href="/cron_log/{{page}}/">{{page}}</a></li>
											        	{% endif %}
											        {% endfor %}
											        {% if cronList.has_next %}
											            <li><a href="/cron_log/{{ cronList.next_page_number }}/">&raquo;</a></li>
											        {% endif %}
											</ul>
                     		            {% endif %}					                            			                   			
										</div>
				                   </div>
				              </div>				              
				           </div>


                            <!-- /.row (nested) -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>    
</div>


<script type="text/javascript">


		$(document).ready(function() {
		    $('#cronTableList').DataTable({
		        responsive: true
		    });
		});

		function deleteCronLogs(obj,id) {
			$.ajax({
				dataType: "JSON",
				url:'/api/logs/cron/'+ id +'/', //请求地址
				type:"DELETE",  //提交类似
				success:function(response){
					var str= 'cronLogs-' + id
					document.getElementById(str).innerHTML = ''; 
				}					
			})					
		}					
  
</script>

{% endblock %}